<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div class="box">1111</div>
    <button>点击</button>
    <script>

        // 通过布尔值 做切换
        var flag = true;
        document.querySelector("button").onclick = function(){
            flag = !flag;
            console.log(flag);
            var str = flag?'张三':'李四';
            document.querySelector(".box").innerHTML = str;
        }



    </script>
</body>
</html>